package com.example.databasepj.controller;

import com.example.databasepj.dto.DishReviewResponse;
import com.example.databasepj.dto.HistoryPriceResponse;
import com.example.databasepj.entity.DishEntity;
import com.example.databasepj.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/dish")
public class DishController {
    @Autowired
    private DishService dishService;

    @GetMapping("/getDishDetail/{dishId}") //展示菜品详细信息
    @ResponseBody
    public DishEntity getDishDetail(@PathVariable int dishId){
        return dishService.selectDishByDishId(dishId);
    }

    @GetMapping("/getPriceHistory/{dishId}") //获取菜品价格浮动信息
    @ResponseBody
    public List<HistoryPriceResponse> getPriceHistory(@PathVariable int dishId){
        return dishService.selectPriceByDishID(dishId);
    }

    @GetMapping("/getReview/{dishId}") //获取菜品评价
    @ResponseBody
    public List<DishReviewResponse> getDishReview(@PathVariable int dishId){
        return dishService.selectReviewByDishId(dishId);
    }


}
